add public calendar  to outlook favorites via script

Hello everyone ,

I am hoping that someone can shed some light and possible help me out.  I have been able to take some script I found online and modify them to add some public folder calendars to "My favorites" list.  Now I would like to be able to have them display under the "other calendars" list.  Currently they do show-up but I have to select them if I want to see them. 

The reason for this endeavor is to prevent our department from taking this same calendars and then pushing all calendar events to each person at out institution. This is time consuming and also only gets sent out to employees on the given day we choose to send it out. After that any new user or if modifications are done are not sent out. We would prefer to just have them access the calendars by default and then if users choose to they can opt out and either remove them or just leave them unchecked.                    

here is  the code we are using oh and I would like to be able to use this for 2013 as well.  I am barely researching this but as of right now it is not working in 2013. Any help would be appreciate it.

Const olPublicFoldersAllPublicFolders = 18
Dim olkApp, olkSes, olkFolder
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNameSpace("MAPI")
'Change the profile name on the next line'
olkSes.Logon "Outlook"
'Change the folder name on the next line.  Repeat the next two lines for each folder you want to add.'
Set olkFolder = olkSes.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("FolderName").Folders("CalendarName")
olkFolder.AddToPFFavorites

olkSes.Logoff
Set olkApp = Nothing
Set olkSes = Nothing
Set olkFolder = Nothing
WScript.Quit

July 5th, 2013 3:13pm

If you mean you want the public folder calendar to be checked and displayed when they open outlook, see http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/

Your code should work in 2013 - what happens when you try it?  

Free Windows Admin Tool Kit Click here and download it now
July 7th, 2013 12:41am

This is great but I want to avoid using macros if possible since I wouldn't want to then include more code to change outlooks macro settings. 

This is the particular error I get: 

Error Line 9 char 1 

olkFolder.AddToPFFavorites

Invalid procedure  call or argument: 'AddToPFFavorites'

Code: 800A0005

July 11th, 2013 11:43am

I'm getting the same error on the code - I use Office 365 with one of the new Exchange 2013 Public Folder Mailboxes. I don't know if the error is the result of that or something else.

Free Windows Admin Tool Kit Click here and download it now
July 13th, 2013 9:21am

I think you make mistake in this Set olkFolder =..."Folder name"... ???

Try to check your destination folder using this code.

Sub WhatFolderName()
Dim olf As MAPIFolder
Set olf = Application.GetNamespace("MAPI").PickFolder
Debug.Print olf.FolderPath
End Sub

Solution U'll ve in immediate window Ctrl+G in VBA

July 15th, 2013 6:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics